package ar.edu.unq.svnpermission.ui.model;

import java.util.List;

import org.apache.wicket.model.IModel;


import ar.edu.unq.svnpermission.domain.Access;
import ar.edu.unq.svnpermission.domain.Folder;
import ar.edu.unq.svnpermission.domain.Membership;
import ar.edu.unq.svnpermission.domain.Permission;
import ar.unq.edu.svnpermission.homes.PermissionHome;
import ar.unq.edu.svnpermission.homes.SvnPermission;

public class FolderDetail extends UseCase implements IModel<FolderDetail>{

	private static final long serialVersionUID = 1L;

	private Folder folder = new Folder();
	
	public FolderDetail(Folder folder)
	{
		this.setFolder(folder);
	}
	
	/**
	 * Asigna los permisos a la Carpeta
	 * @param member Member a quien se le va a asignar el permiso
	 * @param access Listado de Permisos
	 * @author nicolas
	 */
	public void createPermission(Membership member, List<Access> access)
	{
		SvnPermission.getHome(Permission.class,PermissionHome.class).create(new Permission(member, this.getFolder(),access));
	}
	
	/**
	 * Obtiene desde la Home, todos los permissos para la carpeta.
	 * @return Una lista de permisos
	 * @author nicolas
	 */
	public List<Permission> getPermission()
	{
		return this.getHome(Permission.class, PermissionHome.class).getFolderPermissions(this.getFolder());
	}

	public Folder getFolder() {
		return folder;
	}
	
	public String getFolderName()
	{
		return this.getFolder().getName();
	}

	public void setFolder(Folder folder) {
		this.folder = folder;
	}

	public void detach() {
		// TODO Auto-generated method stub
		
	}

	public FolderDetail getObject() {

		return this;
	}

	public void setObject(FolderDetail object) {
	
		
	}
	
	
}
